//
//  AppDelegate.m
//  SZ_iOS
//
//  Created by TuRing on 16/10/13.
//  Copyright © 2016年 You Ran. All rights reserved.
//

#import "AppDelegate.h"
#import "Constants.h"
#import "BaseViewController.h"
#import "HomeViewController.h"
#import "ResourceViewController.h"
#import "DepartmentViewController.h"
#import "CompanyViewController.h"
#import "PlanViewController.h"


@interface AppDelegate ()

@property (nonatomic, strong) UITabBarController *tabBar;

@end

@implementation AppDelegate{
    BMKMapManager *_mapManager;
}

@synthesize window;


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    NSString *mapKey = @"aEdbde3ClItrEexcxHZdNhmrWFaYYqvA";
    _mapManager = [[BMKMapManager alloc]init];
    
    // 如果要关注网络及授权验证事件，请设定generalDelegate参数
    BOOL ret = [_mapManager start:mapKey generalDelegate:nil];
    if (ret) {
        NSLog(@"百度引擎设置成功！");
    }
    
    self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    //创建视图控制器
    [self initTabBarController];
        
    self.window.rootViewController = self.tabBar;
    [self.window makeKeyAndVisible];
    
    return YES;
}

- (void)initTabBarController {
    UINavigationController *navi1 = [[UINavigationController alloc]initWithRootViewController:[[HomeViewController alloc ]init]];
    navi1.tabBarItem.title = TABBAT_TITLE[0];
    navi1.tabBarItem.image = [UIImage imageNamed:@"home"];
    
    UINavigationController *navi2 = [[UINavigationController alloc]initWithRootViewController:[[PlanViewController alloc ]init]];
    navi2.tabBarItem.title = TABBAT_TITLE[1];
    navi2.tabBarItem.image = [UIImage imageNamed:@"warn"];

    
    UINavigationController *navi3 = [[UINavigationController alloc]initWithRootViewController:[[CompanyViewController alloc ]init]];
    navi3.tabBarItem.title = TABBAT_TITLE[2];
    navi3.tabBarItem.image = [UIImage imageNamed:@"company"];
    
    UINavigationController *navi4 = [[UINavigationController alloc]initWithRootViewController:[[DepartmentViewController alloc ]init]];
    navi4.tabBarItem.title = TABBAT_TITLE[3];
    navi4.tabBarItem.image = [UIImage imageNamed:@"department"];
    
    UINavigationController *navi5 = [[UINavigationController alloc]initWithRootViewController:[[ResourceViewController alloc ]init]];
    navi5.tabBarItem.title = TABBAT_TITLE[4];
    navi5.tabBarItem.image = [UIImage imageNamed:@"resource"];
    
    self.tabBar = [[UITabBarController alloc ]init];
    self.tabBar.title = @"预警系统";
    [self.tabBar.navigationController.navigationBar setTintColor:[UIColor blueColor]];
    self.tabBar.viewControllers = @[navi1, navi2, navi3, navi4, navi5];
    
}


- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}


- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


@end
